void StringLength(string s, int &a, int &b) {
	int n = s.length();
	for (; a >= 0 && b < n && s[a] == s[b]; a--, b++);
	a++;b--;
}
string longestPalindrome(string s) {
	if (s.length() == 0)
		return "";
	int left = 0, right = 0, a, b, x, y, n = s.length();
	for (int i = 0; i < n; i++) {
		a = i;b = i;x = i;y = i + 1;
		StringLength(s, a, b);
		StringLength(s, x, y);
		if (right - left < b - a) {
			left = a;
			right = b;
		}
		if (right - left < y - x) {
			left = x;
			right = y;
		}
	}
	return s.substr(left, right - left + 1);
}